package com.example.administrator.jokeyboarddemo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.example.administrator.jokeyboarddemo.fillblank.FillBlank;
import com.example.administrator.jokeyboarddemo.keyboard.KeyboardView;
import com.example.administrator.jokeyboarddemo.keyboard.LayoutEditText;

import java.util.ArrayList;
import java.util.List;

public class TestEditTextActivity extends Activity implements View.OnClickListener {

    private KeyboardView  keyboardView;
    private LayoutEditText layoutEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_edit_text);
        initView();
//        showEditText();
    }

    private void showEditText() {
        layoutEditText.setLayoutEditText(getFillBlank("第一题",3));
    }

    private List<FillBlank> getFillBlank(String question,int count) {
        List<FillBlank> fillBlankList = new ArrayList<>();
        for(int i=0;i<count;i++){
            FillBlank fillBlank = new FillBlank();
            fillBlank.setAnswer(question+i);
            fillBlankList.add(fillBlank);
        }
        return fillBlankList;
    }

    private void initView() {
        findViewById(R.id.btn_last).setOnClickListener(this);
        findViewById(R.id.btn_next).setOnClickListener(this);
        keyboardView = (KeyboardView)findViewById(R.id.keyboard);
        layoutEditText = (LayoutEditText)findViewById(R.id.layout_edits);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_last:
                layoutEditText.setLayoutEditText(getFillBlank("第一题",3));
                break;
            case R.id.btn_next:
                layoutEditText.setLayoutEditText(getFillBlank("第二题",1));
                break;
        }
    }
}
